﻿using System.Collections.Generic;
using System.IO;

namespace ImageProvider
{
    public class ImageCatalogue
    {
        public ImageCatalogue(string name, ImageCatalogue parent = null)
        {
            this.Name = name;
            this.Parent = parent;
            if (Directory.Exists(this.Path) == false)
            {
                Directory.CreateDirectory(this.Path);
            }
        }

        public string Name { get; private set; }

        public ImageCatalogue Parent { get; private set; }

        public string Path
        {
            get
            {
                var stack = new Stack<string>();
                stack.Push(this.Name);
                var parent = this.Parent;
                while (parent != null)
                {
                    stack.Push(parent.Name);
                    parent = parent.Parent;
                }

                var parts = stack.ToArray();
                var result = string.Join("\\", parts);
                return result;
            }
        }
    }
}